package com.guan.core.entity;

import java.util.List;

/**
 * 分页工具类
 * Created by Administrator on 2018/1/26 0026.
 */
public class Page<T>
{
    private int currentPage = 1;//当前页
    private int total;//总记录数
    private int pageNum;//总页数
    private int pageSize;//每页条数
    private PageData pd;//查询参数
    private List<T> result;//存储数据

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
        pageNum = total/pageSize;
        if(total%pageSize !=0){
            pageNum ++;
        }
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public PageData getPd() {
        return pd;
    }

    public void setPd(PageData pd) {
        this.pd = pd;
        if(pd !=null){
            String curPage = pd.getString("currentPage");
            String size = pd.getString("pageSize");
            if(curPage.equals("")){
                currentPage = 1;
            }else{
                currentPage = Integer.valueOf(curPage);
            }
            if(size.equals("")){
                pageSize = 10;
            }else{
                pageSize = Integer.valueOf(size);
            }
        }
    }

    public List<T> getResult() {
        return result;
    }

    public void setResult(List<T> result) {
        this.result = result;
    }
}
